/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.appstreet.dao.impl;

import com.opgea.appstreet.dao.CompanyDAO;
import com.opgea.appstreet.domain.entities.Company;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Ramesh
 */
@Repository
@Transactional
public class CompanyDAOImpl implements CompanyDAO{

    //private Session session = HibernateUtil.getSessionFactory().openSession();
    @Autowired
    private SessionFactory sessionFactory;
    
    @Override
    public Company create(Company company){
        Session session = sessionFactory.openSession();
        Transaction tx = session.getTransaction();
        tx.begin();
        session.save(company);
        tx.commit();
        session.close();
        return company;
    }

}
